package com.example.dayu521.sg_oss.controller.msg;

import com.example.dayu521.sg_oss.controller.ProductTrade;
import com.example.dayu521.sg_oss.domain.Trade;
import com.example.dayu521.sg_oss.service.TradeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.function.Consumer;

@Component("order_pay")
@Slf4j
public class OrderPayedListener implements Consumer<Long> {

    //    @Autowired
//    private TradeService tradeService;
//
//    @Override
//    public void accept(Long order_num) {
//
//        try {
//            if (tradeService.lambdaUpdate().eq(Trade::getBusiness_id, order_num).set(Trade::getPayed, 1).update()) {
//                log.info("订单支付修改完成 {}",order_num);
//            } else {
//                log.error("订单支付状态,修改失败,请检查数据库");
//            }
//        }catch (Exception e){
//            e.printStackTrace();
//            throw e;
//        }
//    }
    @Autowired
    private ProductTrade productTrade;

    @Override
    public void accept(Long order_num) {
        //todo 回查支付结果
//        var res = productTrade.finish_pay(order_num);
//        if (res.is_ok()) {
//
//        } else {
//            throw new RuntimeException(res.info());
//        }
    }
}
